<form id="<?php echo $uniqid;?>" method="post" style="padding: 8px;">
    <table border="0" width="100%" cellspacing="1" cellpadding="5" class="formtable">
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">商品名：</td>
            <td width="80%">{{goods.title}}</td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">规格：</td>
            <td width="80%">{{goods.goods_sku_text}}</td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td class="tlabel">增加库存：</td>
            <td width="80%">
                <input type="text" style="width:400px;" v-model="params.stock"
                       class="forminput inputstyle textbox-text validatebox-text textbox-prompt easyui-validatebox"
                       placeholder="请输入增加库存.." required="true">
            </td>
        </tr>
    </table>
</form>

<script>
    var cpfrVm = new Vue({
        el: '#<?php echo $uniqid;?>',
        data: {
            goods: JSON.parse('<?php echo addslashes($goods);?>'),
            params: {
                id: '<?php echo $id;?>',
                stock: '',
            },
        },
        methods: {
            submit: function () {
                if (!cpfrVm.params.stock || parseInt(cpfrVm.params.stock) < 1) {
                    $.messager.alert('提示', '请输入增加的库存数量', 'warning');
                    return;
                }
                $.post('/merchant/goods/cpfr', cpfrVm.params, function (data) {
                    if (data.ret === 0) {
                        $.messager.show({
                            title: '提示',
                            msg: data.msg,
                            timeout: 3000,
                            showType: 'slide'
                        });
                        $('#<?php echo $uniqid;?>').form('clear');
                        $("#stockwarningDlg").dialog('close');
                        if (typeof (stockwarningReload) == 'function') {
                            stockwarningReload();
                        }
                    } else {
                        $.messager.alert('提示', data.msg, 'warning');
                    }
                });
            }
        }
    });
    $('#stockwarningsubmit').click(function (data) {
        cpfrVm.submit();
    })
</script>
